//
//  UIColor+NED.h
//  ScriptKill
//
//  Created by mac on 2020/6/19.
//  Copyright © 2020 ScriptKill. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, NEDGradDirection) {
    NEDGradDirection_top_down,
    NEDGradDirection_down_top,
    NEDGradDirection_left_right,
    NEDGradDirection_right_left,
    
    NEDGradDirection_leftTop_rightDown,//左上角->右下角
    NEDGradDirection_rightDown_leftTop,
    NEDGradDirection_rightTop_leftDown,
    NEDGradDirection_leftDown_rightTop,
};

struct NEDRGBA {
    CGFloat r;
    CGFloat g;
    CGFloat b;
    CGFloat a;
};
typedef struct CG_BOXABLE NEDRGBA NEDRGBA;

UIColor * NEDColorHex(NSString * hexColor);

@interface UIColor (NED)


- (UIImage *)ned_drawImageWithColor;
- (UIImage *)ned_drawImageWithColorBySize:(CGSize)imageSize;

//暗黑模式下 两个色值
+ (UIColor *)ned_dynamicHexColor:(NSString *)lightColor darkColor:(NSString *)darkColor;
//+ (UIColor *)ned_dynamicColor:(UIColor *)lightColor darkColor:(UIColor *)darkColor;

+ (UIColor *)ned_colorWithHexString:(NSString *)color;
//color:支持@“#123456”、 @“0X123456”、 @“123456”三种格式
+ (UIColor *)ned_colorWithHexString:(NSString *)color alpha:(CGFloat)alpha;

+ (UIColor *)ned_colorWithRGBA:(NEDRGBA)rgba;

/** 渐变 上到下*/
+ (UIColor*)ned_gradientFromColor:(UIColor*)c1 toColor:(UIColor*)c2 withHeight:(NSInteger)height;
/** 渐变 左到右*/
+ (UIColor*)ned_gradientFromColor:(UIColor*)c1 toColor:(UIColor*)c2 withWidth:(NSInteger)width;
/**
 渐变
 @param gradCenter 中心点
 @param gradRadius 半径
 @param direction 方向
 @param locations 数值 0 到 1
 */
+ (UIColor*)ned_gradientFromColors:(NSArray <UIColor*>*)colors locations:(NSArray <NSNumber *>* _Nullable)locations gradCenter:(CGPoint)gradCenter gradRadius:(CGFloat)gradRadius direction:(NEDGradDirection)direction;

/** 颜色平滑过渡*/
+ (UIColor *)ned_transformFromColor:(UIColor*)fromColor toColor:(UIColor *)toColor progress:(CGFloat)progress;

+ (UIColor *)ned_randomColor;


/// 两个颜色是否相同
- (BOOL)ned_isEqualToColor:(UIColor *)toColor;

- (UIColor *)lighterColor:(CGFloat)value;
- (UIColor *)darkerColor:(CGFloat)value;

- (UIColor *(^)(CGFloat alpha))ned_alpha;

@end

NS_ASSUME_NONNULL_END
